{include file="public/header" /}

<style>
    body{
        background: #FFF;
    }

</style>

<div class="page">
    <table class="ds-default-table order">
        <tbody>
        <tr>
            <th>订单基本信息</th>
        </tr>
        <tr>
            <td colspan="2">
                <ul>
                    <li><strong>{$Think.lang.ds_order_sn}:</strong>{$order_info.order_sn}</li>
                    <li><strong>{$Think.lang.order_state}:</strong>{$order_state[$order_info.order_state]}</li>
                    <li><strong>订单类型:</strong>{$order_type[$order_info.order_type]}</li>
                    <li><strong>订单创建时间:</strong>{$order_info.add_time|date="Y-m-d H:i:s",###}</li>
                    <li><strong>订单备注:</strong>{$order_info.remarks}</li>
                    <li><strong>买家账号:</strong>{$order_info.member_name}</li>
                    <li><strong>运营商:</strong>{$order_info.invite_store_name}</li>
                </ul>
            </td>
        </tr>
        <form id="store_form" method="post" novalidate="novalidate">
            <table class="ds-default-table">
                <!--店主账号-->
                <tbody>
                <input type="hidden" name="order_id" value={$order_info.order_id} >

                <tr class="noborder" style="background: rgb(255, 255, 255);">
                    <td style="width: 100px;" class="required">预约电话: </td>
                    <td class="vatop rowform">
                        <input type="text" value="{$order_info.appoint_phone}" name="appoint_phone"  class="txt">
                    </td>
                </tr>

                <tr class="noborder">
                  <td class="w120">预约时间:</td>
                  <td class="vatop rowform">
                    <input style="width: 250px;" id="start_time" value="{$order_info.appointment_time}" name="start_time" type="text" class="text w130"/>
                </td>
              </tr>
              <tr>
                <td colspan="2" class="required">预约地址:
                    <div id="area_s" style="margin-left: 145px;margin-top:-20px;">
                        {$order_info.appoint_address}
                         <input type="button" value="编辑" id="address_edit">
                        <input type="hidden" id="_area_4" value="1">
                    </div>
                    <p id="area_" style="margin-left: 141px; margin-top: -19px;  display:none;">
                        <input type="hidden" value="" name="appoint_address" id="company_address">
                        <input type="hidden" value="" name="appoint_province" id="_area_1">
                        <input type="hidden" value="" name="appoint_city" id="_area_2">
                        <input type="hidden" value="1" name="appoint_district" id="_area_3">
                        <span></span></p></td>
               </tr>
               <tr class="noborder" >
                    <td class="w120"><label class="" for="">详细地址:</label></td>
                    <td class="vatop rowform">
                        <textarea name="appoint_detail_address" class="tarea" >{$order_info.appoint_detail_address}
                       </textarea>
                    </td>
                    <td class="vatop tips"></td>
                </tr>
                <tr class="noborder" style="background: rgb(255, 255, 255);">
                    <td class="required">备注: </td>
                    <td class="vatop rowform"><input type="text" name="remarks" value="{$order_info.remarks}" class="txt"></td>
                    <td class="vatop tips">请输入备注</td>
                </tr>
                </tbody>
                <tfoot>
            <tr class="tfoot">
                <td colspan="15"><input class="btn" type="submit" value="提交"></td>
            </tr>
            </tfoot>
            </table>
        </form>
        </tbody>
    </table>
</div>
<script type="text/javascript" src="{$Think.PLUGINS_SITE_ROOT}/mlselection.js" charset="utf-8"></script>
<script type="text/javascript" src="{$Think.PLUGINS_SITE_ROOT}/jquery.mousewheel.js"></script>
<link rel="stylesheet" href="{$Think.PLUGINS_SITE_ROOT}/js/jquery.lightbox/css/lightbox.min.css">
<script src="{$Think.PLUGINS_SITE_ROOT}/js/jquery.lightbox/js/lightbox.min.js"></script>
<link rel="stylesheet" href="{$Think.PLUGINS_SITE_ROOT}/js/jquery-ui-timepicker/jquery-ui-timepicker-addon.min.css">
<script src="{$Think.PLUGINS_SITE_ROOT}/js/jquery-ui-timepicker/jquery-ui-timepicker-addon.min.js"></script>
<script src="{$Think.PLUGINS_SITE_ROOT}/js/jquery-ui-timepicker/i18n/jquery-ui-timepicker-zh-CN.js"></script>
<script>
    $(function(){
        $('#start_time').datetimepicker({dateFormat: 'yy-mm-dd'});
        $('#end_time').datetimepicker({dateFormat: 'yy-mm-dd'});

    $('div[dstype="editStoreContent"] > ul').find('li').click(function(){
        $(this).addClass('current').siblings().removeClass('current');
        var _index = $(this).index();
        var _form = $('div[dstype="editStoreContent"]').find('form');
        _form.hide();
        _form.eq(_index).show();
    });
});
    //按钮先执行验证再提交表单
    

    $(document).ready(function () {

        /*编辑分类*/
        $('#gc_edit').click(function () {
            $('#gcategorys').remove();
            $('#gcategory').show();
        });

        /*编辑所在地*/
        $('#address_edit').click(function () {
            $('#area_s').remove();
            $('#area_').show();
        });


        /* AJAX选择品牌 */
        $("#ajax_brand").brandinit();

        $('#dssubmit').click(function () {
            $('#formSearch').submit();
        });

        $('#dssubmit').click(function () {
            $('#formSearch').submit();
        });
        $('#company_address').ds_region();
    });
    $(function () {
        // 类型搜索
        $(document).off('change', "#gcategory > select").on("change", "#gcategory > select", function () {
            type_scroll($(this));
        });
        var typeScroll = 0;

        function type_scroll(o) {
            var id = o.val();
            if (!$('#type_dt_' + id).is('dt')) {
                return false;
            }
            $('#type_div').scrollTop(-typeScroll);
            var sp_top = $('#type_dt_' + id).offset().top;
            var div_top = $('#type_div').offset().top;
            $('#type_div').scrollTop(sp_top - div_top);
            typeScroll = sp_top - div_top;
        }

        gcategoryInit('gcategory');

        //图片删除
        $(document).on('click', '.del_img', function () {
            /* var lastId = $(this).parent().parent().parent().find('tr').last().attr('data-id');
             html+="<input type='hidden' name='area_id["+id+"]' value='"+chk_value+"'>";*/
            var data_id = $(this).attr('data_id');
            var data_url = $(this).attr('data_url');
            var html = "<input type='hidden' name='del_pic[" + data_id + "]' value='" + data_url + "' />";
            $(this).parent().remove();
        });


        //图片上传并展示
        $(document).on('change', '#upload_img', function () {
            var files = document.getElementById('upload_img').files[0];
            var lastId = $(this).parent().next().find('span').last().attr('data_id');
            var lastid = parseInt(lastId) + 1;
            var url = $(this).attr('url');
            var obj = $(this).parent().next();
            var formData = new FormData();
            formData.append('file', files);
            $.ajax({
                //请求方式
                type: "POST",
                //请求地址
                url: "ajax_upload",
                data: formData,
                cache: false,  //默认是true，但是一般不做缓存
                processData: false, //用于对data参数进行序列化处理，这里必须false；如果是true，就会将FormData转换为String类型
                contentType: false,  //一些文件上传http协议的关系，自行百度，如果上传的有文件，那么只能设置为false
                //请求成功
                success: function (result) {
                    if (result.err == 0) {
                        layer.msg(result.msg);
                        $('#upload_img').val('');
                        var html = "<span data_id='" + lastid + "'><img src='" + http_name + '/' + result.data + "' width='120' height='120'/><input type='hidden' name='pic[" + lastid + "]'  value='" + result.data + "'  /><input type='button' value='删除' class='del_img' data_id='" + lastid + "' data_url='" + result.data + "'/></span>";
                        obj.append(html);
                    } else {
                        $('#upload_img').val('');
                        alert('文件信息错误,请重新上传');
                        return false;
                    }


                },
                //请求失败，包含具体的错误信息
                error: function (e) {
                    console.log(e.status);
                    console.log(e.responseText);
                }
            });


            /* var lastId = $(this).parent().parent().parent().find('tr').last().attr('data-id');
             html+="<input type='hidden' name='area_id["+id+"]' value='"+chk_value+"'>";*/
            /*  var data_id = $(this).attr('data_id');
              var data_url = $(this).attr('data_url');
              var  html="<input type='hidden' name='del_pic["+data_id+"]' value='"+data_url+"' />";
              $(this).parent().html(html);   */
            /* */

        });

    });

    jQuery.validator.addMethod("checkFCodePrefix", function (value, element) {
        return this.optional(element) || /^[a-zA-Z]+$/.test(value);
    }, '<i class="iconfont">&#xe64c;</i>{$Think.lang.prompt_information1}');
    $("#add_form").validate({
        errorPlacement: function (error, element) {
            $(element).next('span').append(error);
        },
        rules: {
            content: {
                required: true
            },
            goods_name: {
                required: true
            },
            count: {
                required: true,
                digits: true,
                min: 1
            },
            price: {
                required: true,
                number: true,
                min: 0.01
            },
            phone: {
                required: true,
                minlength: 11,
                maxlength: 11,
            }
        },
        messages: {
            content: {
                required: "请填写描述"
            },
            goods_name: {
                required: "不能为空"
            },
            count: {
                required: "不能为空",
                digits: "请设置大于0的整数",
                min: '请设置大于0的整数'
            },
            price: {
                required: "不能为空",
                number: "请设置大于0的整数",
                min: '请设置大于0的整数'
            },
            phone: {
                required: "请输入手机号",
                minlength: "不能小于11个字符",
                maxlength: "不能大于11个字符",
            }
        }
    });


    function confirm() {
        var  _area_3= $('#_area_3').val();
        var _area_1 = $('#_area_1').val();
        var class_id = $('#class_id').val();
        var lastId = $('#upload_img').parent().next().find('span').last().attr('data_id');
        if (_area_3 == ''&&_area_1!='') {
            layer.msg('请选择所在地');
            return false;
        }
        var ress = $("#gcategory").is(":hidden");
        if (!ress&&class_id == '1000000') {
            layer.msg('请选择分类');
            return false;
        }
        var res = $("#area_").is(":hidden");
        if (!res&&_area_1=='') {
            layer.msg('请选择所在地');
            return false;
        }
        if (lastId == '-1') {
            layer.msg('请上传图片');
            return false;
        }
        var res = $('form').valid();
        if (res) {
            var url = $('form').attr('action');
            //alert(url);return false;
            // alert(url);return false;
            $.ajax({
                type: "POST",
                url: url,
                data: $('#add_form').serialize(),// 你的formid

                error: function (request) {
                    alert("Connection error");
                },
                success: function (data) {
                    if (data.code == 0) {

                        layer.msg(data.msg);
                        location.href = data.url;
                        return false;
                    } else {
                        layer.msg(data.msg);
                        location.href = data.url;
                        return false;

                    }
                }
            });return false;
        } else {
            layer.msg('操作失败');
            return false;
        }
    }

</script> 